<template>
  <div style="max-height: 450px; overflow-y: auto">
    <div
      v-for="history of props.dataList"
      :key="history.id"
      class="item"
      @click="toDetail(history.bcontent)"
    >
      <div style="font-size: 12px; color: #787878">
        于&nbsp;{{ titleUtil.formatDate(history.createTime) }}&nbsp;浏览了文章
      </div>
      <div
        style="
          display: flex;
          width: 100%;
          justify-content: space-between;
          height: 40px;
          line-height: 40px;
        "
      >
        <div>{{ titleUtil.title(history.bcontent.title) }}</div>
        <div style="font-size: 12px; color: #787878">
          浏览人数{{ titleUtil.numberTo(history.bcontent.historyPeopleCount) }}
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import titleUtil from '@/util/titleUtil'
import store from '@/store'
import { useRouter } from 'vue-router'

const props = defineProps({
  dataList: {
    type: Array,
    default: () => []
  }
})
const router = useRouter()

const toDetail = (item) => {
  console.log('传递前', item)
  store.dispatch('setBlogItem', item)
  router.push('/blogdetail')
}
</script>

<style lang="scss" scoped>
.item {
  padding: 10px 0;
  border: 1px #eee solid;
  margin-bottom: 10px;
  padding: 5px;
  border-radius: 2px;
  &:hover {
    cursor: pointer;
    color: #ff5100;
    background: #bbc9ff2b;
  }
}
</style>
